<?php
namespace App\Models\Admin;

class AdminModel extends BaseModel
{
    /**
     * 管理员
     */

    protected $table = 'auth_admin';
    protected $fillable = [
        'id','name','role','password','pwd','created_at','updated_at','last_login',
    ];

    public function getRoleName()
    {
        $roleModel = RoleModel::find($this->role);
        return $roleModel ? $roleModel->name : '';
    }

    /**
     * 上次登陆时间
     */
    public function getLastLogin()
    {
        return $this->last_login ? date('Y-m-d H:i',$this->last_login) :
            date('Y-m-d H:i',$this->created_at);
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '昵称',
            'del' => '是否删除'
        ];
    }
}